<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>尤迈桃李会</title>
    <script src="js/rem.js"></script>
    <link rel="stylesheet" href="css/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.min.css">
    <link rel="stylesheet" href="css/public.css">
    <link rel="stylesheet" href="css/user.css">
    <script>(function() {var _53code = document.createElement("script");_53code.src = "https://tb.53kf.com/code/code/96d8f960b261e49515450f8953b044bc5/1";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(_53code, s);})();</script>
</head>
<body>
    <div class="user-auth bgwhite">
        <div class="top-space"></div>
        <p class="pub-user-tit plr15">品牌分享官认证</p>
        <div class="pub-menu space-border plr15">
            <ul class="menu-list">
                <li class="menu-item active">
                    <a href="#">品牌</a>
                </li>
                <li class="menu-item">
                    <a href="#">个人</a>
                </li>
            </ul>
        </div>
        <form action="#" class="shareForm active" data-type="1" autocomplete="off">
            <div class="pub-box space-border plr15">
                <span class="pub-desc"><i class="i-required">*</i>机构名称</span>
                <input class="pub-text" type="text" name="organization" value="">
            </div>
            <div class="pub-box space-border plr15">
                <span class="pub-desc"><i class="i-required">*</i>组织机构代码</span>
                <input class="pub-text" type="text" name="groupCode" value="">
            </div>
            <div class="pub-box space-border plr15">
                <span class="pub-desc"><i class="i-required">*</i>手机号</span>
                <input class="pub-text loginMobileView" type="text" value="">
                <input class="pub-text" type="hidden" name="loginMobile" value="">
            </div>
            <div class="submit-box">
                <input class="pub-submit-btn shareSubmit" type="submit" value="提交申请">
                <div class="btn-wrapper">
                    <a class="choose-identity" href="javascript:history.back(-1)">选择其他身份</a>
                </div>
            </div>
        </form>
        <form action="#" class="shareForm" data-type="2" autocomplete="off">
            <div class="pub-box space-border plr15">
                <span class="pub-desc"><i class="i-required">*</i>姓名</span>
                <input class="pub-text" type="text" name="userName">
            </div>
            <div class="pub-box space-border plr15">
                <span class="pub-desc"><i class="i-required">*</i>手机号</span>
                <input class="pub-text loginMobileView" type="text" value="">
                <input class="pub-text" type="hidden" name="loginMobile" value="">
            </div>
            <div class="submit-box">
                <input class="pub-submit-btn shareSubmit" type="submit" value="提交申请">
                <div class="btn-wrapper">
                    <a class="choose-identity" href="javascript:history.back(-1)">选择其他身份</a>
                </div>
            </div>
        </form>
    </div>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/jquery-weui.min.js"></script>
    <script src="js/md5.js"></script>
    <script src="js/public.js"></script>
    <script>
        // 获取手机号
        var phone = localStorage.getItem('mobile');
        $('[name=loginMobile]').val(phone);
        $('.loginMobileView').val(phoneDesensitization(phone));

        // tab切换
        $('.menu-item').click(function(){
            var itemIndex = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            $('.shareForm').removeClass('active').eq(itemIndex).addClass('active');
        })

        // 认证数据提交
        var subState = false; // 防重
        $('.shareForm').submit(function(){
            if(subState) return false;
            var $this = $(this);
            var shareType = $this.attr('data-type');
            var data = $this.serializeObject();
            var msg = {
                loginMobile: '手机号不能为空'
            };
            if(shareType === '2'){
                msg.userName = '用户名不能为空';
            } else {
                msg.organization = '机构名称不能为空';
                msg.groupCode = '组织机构代码不能为空';
            }

            for(var k in msg){
                if(validEmpty(data[k], msg[k])) return false;
            }
            if(validPhone(data.loginMobile, '手机号格式不正确')) return false;
            var url = getQueryString('type') === 'reAuth' ? '/userMessage/saveShare' : '/userMessage/updateShare';
            subState = true
            // 品牌分享官认证信息保存
            http(url, {
                hasToken: true,
                data: data,
                success: function(res){
                    if(res.code === '01'){
                        // toast('提交成功');
                        toast('资料提交成功，请等待审核');
                        backIndex(1000);
                    }
                },
                complete: function(){
                    subState = false;
                }
            })
            return false;
        })
    </script>
</body>
</html>